From be3af165b9d9f2bd07ed4500f645c6dcb85ec3a4 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 31 Mar 2013 20:03:14 +0000 Subject: [PATCH] Pass constant QStrings by reference for efficieny. A few constant correctness fixes. --- gpsbabel/avltree.cc | 2 +- gpsbabel/avltree.h | 2 +- gpsbabel/garmin_tables.cc | 2 +- gpsbabel/garmin_tables.h | 2 +- gpsbabel/gbfile.cc | 4 ++-- gpsbabel/gbfile.h | 4 ++-- gpsbabel/magellan.h | 2 +- gpsbabel/magproto.cc | 2 +- gpsbabel/navilink.cc | 2 +- gpsbabel/raymarine.cc | 2 +- gpsbabel/unicsv.cc | 2 +- gpsbabel/xmlgeneric.cc | 30 +++++++++++++++--------------- gpsbabel/xmlgeneric.h | 26 +++++++++++++------------- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/gpsbabel/avltree.cc b/gpsbabel/avltree.cc index 70defe12a..ea8bda08f 100644 --- a/gpsbabel/avltree.cc +++ b/gpsbabel/avltree.cc @@ -194,7 +194,7 @@ avltree_find(const avltree_t* tree, const char* key, const void** data) } int -avltree_find(const avltree_t* tree, const QString key, const void** data) +avltree_find(const avltree_t* tree, const QString& key, const void** data) { const char*t = xstrdup(key.toUtf8().data()); int r = avltree_find(tree, t, data); diff --git a/gpsbabel/avltree.h b/gpsbabel/avltree.h index 5feea19dd..2ef88c79d 100644 --- a/gpsbabel/avltree.h +++ b/gpsbabel/avltree.h @@ -79,7 +79,7 @@ avltree_t* avltree_dupe(const avltree_t* tree, const char* module); /* Find key [key] in tree */ int avltree_find(const avltree_t* tree, const char* key, const void** data); -int avltree_find(const avltree_t* tree, const QString key, const void** data); +int avltree_find(const avltree_t* tree, const QString& key, const void** data); /* Get the first (the MIN-) entry of the tree */ const char* avltree_first(const avltree_t* tree, const void** data); diff --git a/gpsbabel/garmin_tables.cc b/gpsbabel/garmin_tables.cc index 366f3f9ed..fb3b7f131 100644 --- a/gpsbabel/garmin_tables.cc +++ b/gpsbabel/garmin_tables.cc @@ -772,7 +772,7 @@ gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, in return DEFAULT_ICON_DESCR; } -int gt_find_icon_number_from_desc(const QString desc, garmin_formats_e garmin_format) +int gt_find_icon_number_from_desc(const QString& desc, garmin_formats_e garmin_format) { static int find_flag = 0; icon_mapping_t* i; diff --git a/gpsbabel/garmin_tables.h b/gpsbabel/garmin_tables.h index 9e06474d0..ce290e6fc 100644 --- a/gpsbabel/garmin_tables.h +++ b/gpsbabel/garmin_tables.h @@ -37,7 +37,7 @@ typedef struct icon_mapping { typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL, GDB} garmin_formats_e; const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic); -int gt_find_icon_number_from_desc(const QString desc, garmin_formats_e garmin_format); +int gt_find_icon_number_from_desc(const QString& desc, garmin_formats_e garmin_format); extern icon_mapping_t garmin_icon_table[]; diff --git a/gpsbabel/gbfile.cc b/gpsbabel/gbfile.cc index 854e86005..32196b6e7 100644 --- a/gpsbabel/gbfile.cc +++ b/gpsbabel/gbfile.cc @@ -1230,7 +1230,7 @@ gbfputcstr(const char* s, gbfile* file) } } int -gbfputcstr(const QString s, gbfile* file) +gbfputcstr(const QString& s, gbfile* file) { return gbfputcstr(qPrintable(s), file); } @@ -1257,7 +1257,7 @@ gbfputpstr(const char* s, gbfile* file) } int -gbfputpstr(const QString s, gbfile* file) +gbfputpstr(const QString& s, gbfile* file) { const char *t = xstrdup(s.toUtf8().data()); int r = gbfputpstr(t, file); diff --git a/gpsbabel/gbfile.h b/gpsbabel/gbfile.h index 0aa9ef72f..369e84fd0 100644 --- a/gpsbabel/gbfile.h +++ b/gpsbabel/gbfile.h @@ -130,9 +130,9 @@ int gbfputint32(const gbint32 i, gbfile* file); int gbfputdbl(const double d, gbfile* file); // write a double value int gbfputflt(const float f, gbfile* file); // write a float value int gbfputcstr(const char* s, gbfile* file); // write string including '\0' -int gbfputcstr(const QString s, gbfile* file); // write string including '\0' +int gbfputcstr(const QString& s, gbfile* file); // write string including '\0' int gbfputpstr(const char* s, gbfile* file); // write as pascal string -int gbfputpstr(const QString s, gbfile* file); // write as pascal string +int gbfputpstr(const QString& s, gbfile* file); // write as pascal string gbsize_t gbfcopyfrom(gbfile* file, gbfile* src, gbsize_t count); diff --git a/gpsbabel/magellan.h b/gpsbabel/magellan.h index 2363c1ef0..e910f029d 100644 --- a/gpsbabel/magellan.h +++ b/gpsbabel/magellan.h @@ -45,7 +45,7 @@ typedef struct icon_mapping { } icon_mapping_t; QString mag_find_descr_from_token(const char* token); -QString mag_find_token_from_descr(QString icon); +QString mag_find_token_from_descr(const QString& icon); unsigned int mag_checksum(const char* const buf); char* m330_cleanse(char* istring); diff --git a/gpsbabel/magproto.cc b/gpsbabel/magproto.cc index 0b5f55b0d..52dff2d3e 100644 --- a/gpsbabel/magproto.cc +++ b/gpsbabel/magproto.cc @@ -1178,7 +1178,7 @@ mag_find_descr_from_token(const char* token) } QString -mag_find_token_from_descr(QString icon) +mag_find_token_from_descr(const QString& icon) { icon_mapping_t* i = icon_mapping; diff --git a/gpsbabel/navilink.cc b/gpsbabel/navilink.cc index d3e175687..1c875daca 100644 --- a/gpsbabel/navilink.cc +++ b/gpsbabel/navilink.cc @@ -174,7 +174,7 @@ static void (*write_route_point)(const waypoint* waypt) = NULL; static void (*write_route_end)(const route_head* track) = NULL; static int -find_icon_from_descr(QString descr) +find_icon_from_descr(const QString& descr) { unsigned int i; diff --git a/gpsbabel/raymarine.cc b/gpsbabel/raymarine.cc index 403adf5a4..8d08f5339 100644 --- a/gpsbabel/raymarine.cc +++ b/gpsbabel/raymarine.cc @@ -140,7 +140,7 @@ static raymarine_symbol_mapping_t raymarine_symbols[] = { #define RAYMARINE_STD_SYMBOL 3 static int -find_symbol_num(const QString descr) +find_symbol_num(const QString& descr) { if (!descr.isNull()) { diff --git a/gpsbabel/unicsv.cc b/gpsbabel/unicsv.cc index bd7f83ffa..df804d2cd 100644 --- a/gpsbabel/unicsv.cc +++ b/gpsbabel/unicsv.cc @@ -1305,7 +1305,7 @@ unicsv_print_str(const char *str) } static void -unicsv_print_str(const QString s) +unicsv_print_str(const QString& s) { char *t = xstrdup(s.toUtf8().data()); unicsv_print_str(t); diff --git a/gpsbabel/xmlgeneric.cc b/gpsbabel/xmlgeneric.cc index 4c99ce3e8..462434614 100644 --- a/gpsbabel/xmlgeneric.cc +++ b/gpsbabel/xmlgeneric.cc @@ -53,8 +53,8 @@ write_xml_header(gbfile *ofd) } void -write_xml_entity(gbfile *ofd, QString indent, - QString tag, QString value) +write_xml_entity(gbfile *ofd, const QString& indent, + const QString& tag, const QString& value) { char *tmp_ent = xml_entitize(value.toAscii().data()); gbfprintf(ofd, "%s<%s>%s\n", qPrintable(indent), qPrintable(tag), tmp_ent, qPrintable(tag)); @@ -62,8 +62,8 @@ write_xml_entity(gbfile *ofd, QString indent, } void -write_optional_xml_entity(gbfile *ofd, const QString indent, - const QString tag, const QString value) +write_optional_xml_entity(gbfile *ofd, const QString& indent, + const QString& tag, const QString& value) { if (!value.isEmpty()) { write_xml_entity(ofd, indent, tag, value); @@ -71,32 +71,32 @@ write_optional_xml_entity(gbfile *ofd, const QString indent, } void -write_xml_entity_begin0(gbfile *ofd, const QString indent, - const QString tag) +write_xml_entity_begin0(gbfile *ofd, const QString& indent, + const QString& tag) { gbfprintf(ofd, "%s<%s>\n", indent.toAscii().data(), tag.toAscii().data()); } void -write_xml_entity_begin1(gbfile *ofd, const QString indent, - const QString tag, const QString attr, - const QString attrval) +write_xml_entity_begin1(gbfile *ofd, const QString& indent, + const QString& tag, const QString& attr, + const QString& attrval) { gbfprintf(ofd, "%s<%s %s=\"%s\">\n", indent.toAscii().data(), tag.toAscii().data(), attr.toAscii().data(), attrval.toAscii().data()); } void -write_xml_entity_begin2(gbfile *ofd, const QString indent, - const QString tag, const QString attr1, - const QString attrval1, const QString attr2, - const QString attrval2) +write_xml_entity_begin2(gbfile *ofd, const QString& indent, + const QString& tag, const QString& attr1, + const QString& attrval1, const QString& attr2, + const QString& attrval2) { gbfprintf(ofd, "%s<%s %s=\"%s\" %s=\"%s\">\n", indent.toAscii().data(), tag.toAscii().data(), attr1.toAscii().data(), attrval1.toAscii().data(), attr2.toAscii().data(), attrval2.toAscii().data()); } void -write_xml_entity_end(gbfile *ofd, const QString indent, - const QString tag) +write_xml_entity_end(gbfile *ofd, const QString& indent, + const QString& tag) { gbfprintf(ofd, "%s\n", indent.toAscii().data(), tag.toAscii().data()); } diff --git a/gpsbabel/xmlgeneric.h b/gpsbabel/xmlgeneric.h index 27e2b69ae..77ad6c0d3 100644 --- a/gpsbabel/xmlgeneric.h +++ b/gpsbabel/xmlgeneric.h @@ -37,20 +37,20 @@ typedef struct xg_tag_mapping { extern char* xhtml_entities; -void write_xml_entity(gbfile* ofd, const QString indent, - const QString tag, const QString value); -void write_xml_entity_begin0(gbfile* ofd, const QString indent, - const QString tag); -void write_xml_entity_begin1(gbfile* ofd, const QString indent, - const QString tag, const QString attr1, - const QString attrval1); -void write_xml_entity_begin2(gbfile* ofd, const QString indent, const QString tag, - const QString attr1, const QString attrval1, - const QString attr2, const QString attrval2); -void write_xml_entity_end(gbfile* ofd, const QString indent, const QString tag); +void write_xml_entity(gbfile* ofd, const QString& indent, + const QString& tag, const QString& value); +void write_xml_entity_begin0(gbfile* ofd, const QString& indent, + const QString& tag); +void write_xml_entity_begin1(gbfile* ofd, const QString& indent, + const QString& tag, const QString& attr1, + const QString& attrval1); +void write_xml_entity_begin2(gbfile* ofd, const QString& indent, const QString& tag, + const QString& attr1, const QString& attrval1, + const QString& attr2, const QString& attrval2); +void write_xml_entity_end(gbfile* ofd, const QString& indent, const QString& tag); -void write_optional_xml_entity(gbfile* ofd, const QString ndent, - const QString tag, const QString value); +void write_optional_xml_entity(gbfile* ofd, const QString& indent, + const QString& tag, const QString& value); void xml_write_time(gbfile* ofd, const time_t timep, int microseconds, const char* elname); void xml_fill_in_time(char* time_string, const time_t timep, int microseconds, int long_or_short); -- 2.30.2